package top.szhome.framework.starter.boot.jackson;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

/**
 * @author 唐加利
 * @date 2023/8/3
 **/
public class Jackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {

    public Jackson2HttpMessageConverter(ObjectMapper objectMapper) {
        super(enhanceObjectMapper(objectMapper));
    }

    private static ObjectMapper enhanceObjectMapper(ObjectMapper objectMapper) {
        // 拷贝 readObjectMapper
        ObjectMapper writeObjectMapper = objectMapper.copy();
        // 大数字 转 字符串
        writeObjectMapper.registerModules(SzhomeJavaTimeModule.INSTANCE);
        return writeObjectMapper;
    }

}
